package leetcode_core.leetcode_2;

public class GetIntersectionNode {

    public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
        ListNode p1 = headA,p2 = headB;
        while (p1!=p2){//返回任意一个均可
            if(p1.next== null){
                p1=headB;
            }else{
                p1=p1.next;
            }
            if(p2.next == null){
                p2=headA;
            }else{
                p2=p2.next;
            }
        }
        return p1;
    }


}
